import { Component, ChangeDetectionStrategy, Input, ViewChild, ElementRef } from "@angular/core";
import { GovernanceIndicatorModel } from "../../models/companyGovernanceIndicator.model";
import { NgxSmartModalService } from "ngx-smart-modal";
import { AnalyticsService } from "../../../../../../shared/services/googleAnalytics.service";
import { GoogleAnalyticsBeacon } from "../../../../../../shared/models/googleAnalytics.model";

/**
 * Company governance indicator component
 *
 * Author: Sorin Spiru
 * Date: 26.02.2018
 */
@Component({
    moduleId: module.id,
    selector: 'governance-indicator',
    templateUrl: 'companyGovernanceIndicator.component.html',
    changeDetection: ChangeDetectionStrategy.OnPush
})
export class CompanyGovernanceIndicatorComponent {
    public expanded: boolean;
    private noExpand: boolean;

    constructor(
        public ngxSmartModalService: NgxSmartModalService,
        private analyticsService: AnalyticsService) {}
    
    @ViewChild('panelLink') panelLink: ElementRef;

    @Input() indicatorIndex: number;

    @Input() indicator: GovernanceIndicatorModel;

    @Input() companyId: string;

    public showIndicator(id: string){        
        this.analyticsService.sendBeacon(new GoogleAnalyticsBeacon('CG Indicators', 'Research', { CompanyId: this.companyId, IndicatorId: id }));
        this.ngxSmartModalService.getModal('indicator' + id).open();
    }
}
